package com.kaiyiweitong.tongxing.activity.my.person_info;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;

import com.kaiyiweitong.tongxing.R;
import com.kaiyiweitong.tongxing.activity.my.PersonInfoActivity;
import com.kaiyiweitong.tongxing.base.BaseActivity;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/12/19 0019.
 */

public class SetSexActivity extends BaseActivity {
    @Bind(R.id.iv_male_choose)
    ImageView mIvMaleChoose;
    @Bind(R.id.iv_female_choose)
    ImageView mIvFemaleChoose;
    private String mSex;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_set_sex);
        ButterKnife.bind(this);
        init();
    }

    private void init() {
        if (getIntent().getStringExtra("sex") != null && !getIntent().getStringExtra("sex").equals("")) {
            mSex = getIntent().getStringExtra("sex");
            if (mSex == "1") {
                mIvMaleChoose.setVisibility(View.VISIBLE);
                mIvFemaleChoose.setVisibility(View.INVISIBLE);
            } else if (mSex == "2") {
                mIvMaleChoose.setVisibility(View.INVISIBLE);
                mIvFemaleChoose.setVisibility(View.VISIBLE);
            }
        }
    }

    @OnClick({R.id.rl_male_choose, R.id.rl_female_choose, R.id.finish})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.rl_male_choose:
                mSex = "1";
                mIvMaleChoose.setVisibility(View.VISIBLE);
                mIvFemaleChoose.setVisibility(View.INVISIBLE);
                break;
            case R.id.rl_female_choose:
                mSex = "2";
                mIvMaleChoose.setVisibility(View.INVISIBLE);
                mIvFemaleChoose.setVisibility(View.VISIBLE);
                break;
            case R.id.finish:
                Intent intent = new Intent(this, PersonInfoActivity.class);
                intent.putExtra("sex", mSex);
                setIntent(intent);
                finish();
                break;
        }
    }
}
